package org.cms.nio.util;

/**
 * @Description: 
 * @Department:
 * @author andy.lhc
 * @date 2016年6月2日 上午10:04:08 
 */
public class ConnectIdGenerator {

  private static final long MAX_VALUE = Long.MAX_VALUE;
  private static ConnectIdGenerator instance=new ConnectIdGenerator();
  public static ConnectIdGenerator getINSTNCE()
  {
      return instance;
  }
  private long connectId = 0L;
  private final Object lock = new Object();

  public long getId() {
      synchronized (lock) {
          if (connectId >= MAX_VALUE) {
              connectId = 0L;
          }
          return ++connectId;
      }
  }
}